﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using System.Windows.Forms;

namespace Atentis_Connector
{
	public partial class IndQueryForm : Form
	{
		public IndQueryForm()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Событие - "Есть запрос SQL"
		/// </summary>
		public event EventHandler IndSelected;

		void OnIndSelected(AtentisConnectorEventArgs e)
		{
			EventHandler indSelected = IndSelected;
			if (indSelected != null)
				indSelected(this, e);
		}

		private void IndQueryForm_Load(object sender, EventArgs e)
		{
			btnUseThisInd.Enabled = false;
		}

		private void lbAllInds_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (lbAllInds.SelectedIndex >= 0)
			{
				btnUseThisInd.Enabled = true;
			}
		}

		private void btnUseThisInd_Click(object sender, EventArgs e)
		{
			var acea = new AtentisConnectorEventArgs(lbAllInds.Items[lbAllInds.SelectedIndex].ToString());

			OnIndSelected(acea);
		}
	}
}
